package com.fcscs.cservice.client.main.configuration.activitylog;

import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
import com.fcscs.core.gwt.common.CoreConstants;
import com.fcscs.core.gwt.common.FormSubmitListener;
import com.fcscs.core.gwt.common.ui.BaseFormDialog;
import com.fcscs.core.gwt.common.ui.FcsFields.FormButton;
import com.fcscs.core.gwt.common.ui.FcsFormPanel;
import com.fcscs.cservice.client.common.CServiceConstants;
import com.fcscs.cservice.domain.Restaurant;

public class ActivityDetailDialog extends BaseFormDialog<Restaurant> {
	private static ActivityDetailDialog INSTANCE;
	private MyFormPanel myFormPanel;
	private VerticalPanel vp;
	private HorizontalPanel hp1;
	private LayoutContainer lc1;
	private Label userLab;
	private TextField<String> userText;
	private HorizontalPanel hp2;
	private LayoutContainer lc2;
	private Label timeLab;
	private TextField<String> timeText;
	private HorizontalPanel hp3;
	private LayoutContainer lc3;
	private Label dateLab;
	private TextField<String> dateText;

	private HorizontalPanel hp4;
	private LayoutContainer lc4;
	private Label actionTypeLab;
	private TextField<String> actionTypeText;
	private TextArea logArea;
	private FormButton cancelBtn;

	public static ActivityDetailDialog getInstance() {
		if (null == INSTANCE) {
			INSTANCE = new ActivityDetailDialog();
		}
		INSTANCE.setHeading(CServiceConstants.CSERVICE_CONSTANTS.bookingDetail());
		return INSTANCE;
	}

	public ActivityDetailDialog() {
		myFormPanel = new MyFormPanel(null);
		setSize(600, 470);
		add(myFormPanel);
	}

	public class MyFormPanel extends FcsFormPanel<Restaurant> {

		protected MyFormPanel(FormSubmitListener<Restaurant> l) {
			super(l);
			setBorders(false);
			setHeaderVisible(false);

			vp = new VerticalPanel();
			vp.setId("ActivityDetailDialog_vp");
			vp.setSpacing(5);

			hp1 = new HorizontalPanel();
			hp1.setId("ActivityDetailDialog_hp1");
			vp.add(hp1);

			lc1 = new LayoutContainer();
			lc1.setId("ActivityDetailDialog_lc1");
			lc1.setLayout(new ColumnLayout());
			hp1.add(lc1);

			userLab = new Label(CoreConstants.CORE_CONSTANTS.user() + CServiceConstants.FIELD_SEP);
			userLab.setId("ActivityDetailDialog_userLab");
			lc1.add(userLab, new ColumnData(100));

			userText = new TextField<String>();
			userText.setId("ActivityDetailDialog_userText");
			userText.setReadOnly(true);
			lc1.add(userText, new ColumnData(200));

			hp2 = new HorizontalPanel();
			hp2.setId("ActivityDetailDialog_hp2");
			vp.add(hp2);

			lc2 = new LayoutContainer();
			lc2.setId("ActivityDetailDialog_lc2");
			lc2.setLayout(new ColumnLayout());
			hp2.add(lc2);

			timeLab = new Label(CoreConstants.CORE_CONSTANTS.time() + CServiceConstants.FIELD_SEP);
			timeLab.setId("ActivityDetailDialog_timeLab");
			lc2.add(timeLab, new ColumnData(100));

			timeText = new TextField<String>();
			timeText.setId("ActivityDetailDialog_timeText");
			timeText.setReadOnly(true);
			lc2.add(timeText, new ColumnData(200));

			hp3 = new HorizontalPanel();
			hp3.setId("ActivityDetailDialog_hp3");
			vp.add(hp3);

			lc3 = new LayoutContainer();
			lc3.setId("ActivityDetailDialog_lc3");
			lc3.setLayout(new ColumnLayout());
			hp3.add(lc3);

			dateLab = new Label(CoreConstants.CORE_CONSTANTS.date() + CServiceConstants.FIELD_SEP);
			dateLab.setId("ActivityLogPanel_dateLab");
			lc3.add(dateLab, new ColumnData(100));

			dateText = new TextField<String>();
			dateText.setId("ActivityDetailDialog_dateText");
			dateText.setReadOnly(true);
			lc3.add(dateText, new ColumnData(200));

			hp4 = new HorizontalPanel();
			hp4.setId("ActivityDetailDialog_hp3");
			vp.add(hp4);

			lc4 = new LayoutContainer();
			lc4.setId("ActivityDetailDialog_hp4");
			lc4.setLayout(new ColumnLayout());
			hp4.add(lc4);

			actionTypeLab = new Label(CServiceConstants.CSERVICE_CONSTANTS.activityType()
					+ CServiceConstants.FIELD_SEP);
			actionTypeLab.setId("ActivityLogPanel_actionTypeLab");
			lc4.add(actionTypeLab, new ColumnData(100));

			actionTypeText = new TextField<String>();
			actionTypeText.setId("ActivityDetailDialog_actionTypeText");
			actionTypeText.setReadOnly(true);
			lc4.add(actionTypeText, new ColumnData(200));

			logArea = new TextArea();
			logArea.setId("ActivityLogPanel_logArea");
			logArea.setReadOnly(true);
			logArea.setSize(560, 250);
			vp.add(logArea);

			cancelBtn = new FormButton(CoreConstants.CORE_CONSTANTS.cancel());
			cancelBtn.setId("PublicAreaEConnectDialog_cancelBtn_Id");
			cancelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
				@Override
				public void componentSelected(ButtonEvent ce) {
					ActivityDetailDialog.this.hide();
					cancelBtn.removeStyleName(CoreConstants.CSS_FORM_BUTTON_FOCUS);
				}
			});
			getButtonBar().add(cancelBtn);

			add(vp);

		}

		@Override
		public void updateForm(Restaurant entity) {
		}

		@Override
		public void populateEntity(Restaurant entity) {
		}

		@Override
		public void setFocus() {
		}

	}

	@Override
	protected FcsFormPanel<Restaurant> getFormPanel() {
		return null;
	}

}
